package com.tianji.aigc.controller;

import com.tianji.aigc.service.ChatSessionService;
import com.tianji.aigc.vo.ChatHistoryVO;
import com.tianji.aigc.vo.SessionVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 会话控制类
 * @Author: lemon
 * @CreateTime: 2025-06-06  19:41
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/session")
@RequiredArgsConstructor
public class SessionController {

    private final ChatSessionService chatSessionService;

    /**
     * 新建会话
     * @param num  生成热门问题的数量，默认为 3
     * @return
     */
    @PostMapping
    public SessionVO createSession(@RequestParam(value = "n", defaultValue = "3") Integer num){
        return chatSessionService.createSession(num);
    }


    /**
     * 查询热门问题
     * @param num 热门问题的数量，默认为 3
     * @return
     */
    @GetMapping("/hot")
    public List<SessionVO.Example> queryHotQuestion(@RequestParam(value = "n", defaultValue = "3") Integer num){
        return chatSessionService.queryHotQuestion(num);
    }


    /**
     * 查询会话详情
     * @param sessionId
     * @return
     */
    @GetMapping("/{sessionId}")
    public List<ChatHistoryVO> queryChatHistory(@PathVariable("sessionId") String sessionId){
        return chatSessionService.queryChatHistory(sessionId);
    }
}
